#!/usr/bin/python
import subprocess
import re
def command(comm):
	out =  subprocess.Popen([comm], stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.read()
	return filter(lambda x: not re.match(r'^\n', x), out)	
def replacer(find, replace, file):
	subprocess.call(['sed '+'-i '+'s/'+find+'/'+replace+'/g '+file], shell=True)

#replacer("BYE", "Foor", "hello")
if command("getenforce") == "Disabled":
	print "SELinux is diabled"
	print "Enabling SELinux"
	replacer("SELINUX=disabled", "SELINUX=enforcing", "config")
	print "SELinux has been enabled. Please reboot your machine to affect that changes."
	print "Please note that, first boot after enabling SELinux will take very long time to re-lable whole system !!!"



print "end"
